package case3;

import java.util.Timer;
import java.util.TimerTask;

public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        //定时器
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("执行定时器的任务");
            }
        },1000);
        System.out.println("程序启动");
        Thread.sleep(4000);
        timer.cancel();
    }
}
